<extend name="Public/base"/>

<block name="body">
    <div class="main-title">
        <h2>邮箱列表</h2>
    </div>


<div class="with-padding">
<div class="btn-group">
    <a class="btn" href="{:U('Admin/Addons/adminList',array('name'=>'Mail'))}">邮件配置</a>
    <a class="btn btn-warning" href="{:addons_url('Mail://Mail/mailList')}">邮箱列表</a>
    <a class="btn" href="{:addons_url('Mail://Mail/sendEmail')}">发送邮件</a>
    <a class="btn" href="{:addons_url('Mail://Mail/history')}">邮件历史</a>
</div>
</div>
<div class="with-padding"> 
        <!-- 高级搜索 -->
        <div class="search-form pull-right">
            <form action="{:addons_url('Mail://Mail/sendEmail')}" method="get">
            <div class="input-group">
                <input type="text" name="address" class="text form-control pull-left" value="{:I('address')}" placeholder="请输入邮箱地址">
                <span class="input-group-btn"><a class="btn btn-primary" href="javascript:;" id="search" url="{:addons_url('Mail://Mail/mailList')}"><i class="icon-search"></i></a></span>
            </div>
            </form>
        </div>
<form action="{:addons_url('Mail://Mail/sendEmail')}" method="post">
    <div style="margin-bottom:10px">
        <a class="btn" href="{:addons_url('Mail://Mail/addEmail')}">新 增</a>
        <button class="btn ajax-post btn" url="{:addons_url('Mail://Mail/delEmail')}" target-form="ids">删除</button>
        <button type="submit" class="btn">发送邮件</button>
    </div>


        <table class="table table-bordered table-striped">
            <thead>
            <tr>
                <th class="row-selected">
                    <input class="checkbox check-all" type="checkbox">
                </th>
                <th>ID</th>
                <th>邮箱地址</th>

            </tr>
            </thead>
            <tbody>
            <notempty name="mailList">
                <volist name="mailList" id="vo">
                    <tr>
                        <td><input class="ids row-selected" type="checkbox" name="ids[]" value="{$vo.id}"></td>
                        <td>{$vo.id}</td>
                        <td>{$vo.address}</td>
                    </tr>
                </volist>
                <else/>
                <td colspan="6" class="text-center"> aOh! 暂时还没有内容! </td>
            </notempty>
            </tbody>
        </table>
</form>
</div>
</block>

<block name="script">
    <script type="text/javascript">
        $(function(){
            //搜索功能
            $("#search").click(function(){
                var url = $(this).attr('url');
                var query  = $('.search-form').find('input').serialize();
                query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
                query = query.replace(/^&/g,'');
                if( url.indexOf('?')>0 ){
                    url += '&' + query;
                }else{
                    url += '?' + query;
                }
                window.location.href = url;
            });
            //回车搜索
            $(".search-input").keyup(function(e){
                if(e.keyCode === 13){
                    $("#search").click();
                    return false;
                }
            });

        });
    </script>
</block>